package proj1;
import java.util.*;

public class Node {

    public State state;
    public int depth;
    public Node parent;
    public int pathCost;
    public int heuristic;

    /**
     * The main constructor for constructing a search node. 
     *
     *   @param state the state that resides at this node
     *   @param depth the search depth of this node
     *   @param parent the parent of this node
     *   @param pathCost the path cost from the root node to this node
     */
    public Node(State state,
		int depth,
		Node parent,int pathCost, int heuristic) {
	this.state = state;
	this.depth = depth;
	this.parent = parent;
	this.pathCost=pathCost;
	this.heuristic=heuristic;
    }

    /**
     * Expands this node, in other words, computes all of the nodes
     * immediately reachable from this node.
     * @param visualize 
     */
    public LinkedList<Node> expand(String strategy, boolean visualize) {
    	LinkedList<State> newStates = state.expand(visualize);
    	LinkedList <Node> newNodes = new LinkedList<Node>();

		for (int i = 0; i < newStates.size(); i++){
			newNodes.add(new Node(newStates.get(i), depth+1, this,0, 0)) ;
		}
		  
		return newNodes;
    }
    

}
